<script setup lang="ts">
import {useRouter} from "vue-router";
import TeamCardList from "../components/TeamCardList.vue";
import {onMounted, ref} from "vue";
import myAxios from "../plugins/myAxios.ts";
import {showFailToast} from "vant";
import {getCurrentUser} from "../service/user.ts";

const router = useRouter();
// 跳转到加入队伍页

const teamList = ref([])
const currentUser = ref()


onMounted(async () => {
  currentUser.value = await getCurrentUser()
  const res = await myAxios.get("/team/list", {
    params: {
      userId: currentUser.value.id
    }
  })
  if (res.code === 200) {
    teamList.value = res.data;
  } else {
    showFailToast('加载队伍失败，请刷新重试')
  }
})
</script>

<template>
  <div id="teamPage">
    <team-card-list :team-list="teamList" />
    <van-empty v-if="teamList?.length < 1" description="数据为空"/>
  </div>
</template>

<style scoped>

</style>
